import { Component, OnInit, Input } from '@angular/core';
import QRCode from 'qrcode';

@Component({
  selector: 'app-advertise',
  templateUrl: './advertise.component.html',
  styleUrls: ['./advertise.component.scss'],
})
export class AdvertiseComponent implements OnInit {
  @Input() tagData: any;
  qrCodeUrl: any;

  constructor() { }

  ngOnInit() {
    // this.demo();
    QRCode.toDataURL(this.tagData.data.qrcode)
      .then(url => {
        console.log(url);
        this.qrCodeUrl = url;
      })
      .catch(err => {
        console.log('QRCode.toDataURL' + err);
      });
  }
  demo() {
    this.tagData = {
      type: "tag",
      style: "advertiseTag",
      name: "advertiseTag",
      linearLayout: "body",
      data: {
        phone: "18888888888",
        qrcode: "http://",
        footInfo: "深圳蜂喔网络科技有限公司",
        questions: [ // 原 有
          // {
          //     "q":"有房出租？",
          //     "a":"直接跟客户谈"
          // },
          // {
          //     "q":"要买房子？",
          //     "a":"直接跟业主谈"
          // }
        ],
        infoDetail: "蜂喔是专注于物业线上交易的信息服务平台，涉及二手房、新房、商铺、厂房、写字楼的租售转让业务、物业装修、房产装修、房屋维护等业务。",
        img: "http://zeno-img.oss-cn-shenzhen.aliyuncs.com/file_1624678256329d384db2966066d265c02100b61044e25.gif",
        privilege: [ // 一列
          {
            no: "1",
            label: "承接各类装修、房屋维修修护订单"
          },
          {
            no: "2",
            label: "也可以代售门店厂价直供的建材，拿提成"
          }
        ],
        privilege_2: [ // 两列
          {
            no: "1",
            label: "房产租售和商铺转让"
          },
          {
            no: "2",
            label: "建材家居的直销"
          },
          {
            no: "3",
            label: "房产租售和商铺"
          },
          {
            no: "4",
            label: "建材家居的直销"
          }
        ],
        logo: "true", // 有logo
        symbol: "true",  // 有大引号
        name: "Json",
        tip: "扫码开通服务",
        bgImg: "https://zeno-img.oss-cn-shenzhen.aliyuncs.com/file_1618205930537de70f37c8f5915b935a91166b89a8689.png",
        tag: "深圳",
        info: "真实房源<font color='red'>9.9</font>"
      }
    };
  }
}
